package com.heima.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.heima.common.PageResult;
import com.heima.mapper.SkuMapper;
import com.heima.pojo.Sku;
import com.heima.pojo.vo.SkuVo;
import com.heima.service.ISkuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SkuServiceImpl extends ServiceImpl<SkuMapper, Sku> implements ISkuService {
    @Autowired
    private SkuMapper skuMapper;


    /**
     * 分页查询商品
     * @param skuName 商品名称
     * @return
     */
    @Override
    public PageResult<SkuVo> search(PageResult<SkuVo> pageResult, String skuName) {
        Page page = new Page<>(pageResult.getPageIndex(), pageResult.getPageSize());
        skuMapper.pageSearch(page, skuName);
        return pageResult.of(page, SkuVo.class);
    }

}
